/**
 * 版权所有：厦门市巨龙信息科技有限公司
 * Copyright 2023 Xiamen Dragoninfo Eng. Co. Ltd.
 * All right reserved.
 */
package com.github.alfred.handler;

import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;

/**
 * 类说明
 *
 * @author chengh
 * @date 2023/12/25 17:38
 */
public class LowKeyHandler {

    private LowKeyHandler() {

    }

    /**
     * 转驼峰
     *
     * @param map
     * @return
     */
    public static Map<String, Object> toLowerCamelCase(Map<String, Object> map) {
        Map<String, Object> resultMap = Maps.newHashMap();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            resultMap.put(StrUtil.toCamelCase(entry.getKey().toLowerCase()), entry.getValue());
        }
        return resultMap;
    }

    /**
     * @param list
     * @return
     */
    public static List<Map<String, Object>> toLowerCamelCase(List<Map<String, Object>> list) {
        List<Map<String, Object>> resultList = Lists.newArrayList();
        for (Map<String, Object> map : list) {
            resultList.add(toLowerCamelCase(map));
        }
        return resultList;
    }

    /**
     * 转下划线
     *
     * @param map
     * @return
     */
    public static Map<String, Object> toUnderLineCase(Map<String, Object> map) {
        Map<String, Object> resultMap = Maps.newHashMap();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            resultMap.put(StrUtil.toUnderlineCase(entry.getKey()), entry.getValue());
        }
        return resultMap;
    }

    public static List<Map<String, Object>> toUnderLineCase(List<Map<String, Object>> list) {
        List<Map<String, Object>> resultList = Lists.newArrayList();
        for (Map<String, Object> map : list) {
            resultList.add(toUnderLineCase(map));
        }
        return resultList;
    }

}
